import type { ProColumns } from '@ant-design/pro-table';
import { listFeeCategoris } from './service'

export type columnsDataType = {
  id: number,
  order: number,
  configurationDate: string
  serviceChargeNo: string,
  effectiveDate: string,
  expirationDate: string,
  state: string,
  rate: string,
  chargeAmount: string,
  maxChargeAmount: string,
};
const columnsData: ProColumns<columnsDataType>[] = [

  // 配置搜索框
  {
    title: '费率编码',
    dataIndex: 'feeCde',
    hideInTable: true,
    fieldProps: {
      maxLength: 20
    },
  },
  {
    title: '费率类别',
    dataIndex: 'feeTypeId',
    hideInTable: true,
    valueType: 'select',
    request: (a) => listFeeCategoris({}).then((res: any) => {
      console.log(res);

      let data: any = [];
      res.body.filter((item: any) => item).map((item: any, index: number) => {
        data[index] = {
          value: item.feeTypeId,
          label: item.feeType
        }
      })
      return data
    })
  },
  {
    title: '规则状态',
    dataIndex: 'status',
    valueType: 'select',
    hideInTable: true,
    valueEnum: {
      0: { text: '未生效' },
      1: {
        text: '生效',

      },
      2: {
        text: '失效',
      }
    },
  },
  {
    title: '配置日期',
    dataIndex: 'configurationDate',
    valueType: 'dateRange',
    colSize: 1,
    hideInTable: true,
    search: {
      transform: (value) => {
        return {
          createDateStart: value[0],
          createDateEnd: value[1],
        };
      },
    },
  },
  {
    title: '生效时间',
    dataIndex: 'effectiveDate',
    colSize: 1,
    valueType: 'dateRange',
    hideInTable: true,
    search: {
      transform: (value) => {
        return {
          effDteStart: value[0],
          effDteEnd: value[1],
        };
      },
    },
  },

  // table里面的内容
  {
    title: '序号',
    dataIndex: 'order',
    valueType: 'indexBorder',
    width: 50,
    fixed: 'left',
  },
  {
    title: '费率编码',
    dataIndex: 'feeCde',
    hideInSearch: true,
    width: 160,
    fixed: 'left',
  },
  {
    title: '费率类别',
    dataIndex: 'feeType',
    hideInSearch: true,
    width: 100,
  },
  {
    title: '配置时间',
    dataIndex: 'createDate',
    hideInSearch: true,
    width: 150,
  },
  {
    title: '生效时间',
    dataIndex: 'effDte',
    hideInSearch: true,
    width: 150
  },
  {
    title: '失效时间',
    dataIndex: 'expDte',
    hideInSearch: true,
    width: 150
  },
  {
    title: '规则状态',
    dataIndex: 'status',
    valueType: 'select',
    hideInSearch: true,
    width: 80,
    valueEnum: {
      1: {
        text: '生效',
        status: 'Success',
      },
      2: {
        text: '失效',
        status: 'Error',
      },
      0: {
        text: '未生效',
        status: 'Default',
      },
    },
  },
  {
    title: '费率',
    hideInSearch: true,
    dataIndex: 'fee',
    width: 100
  },
  {
    title: '手续费/笔',
    hideInSearch: true,
    dataIndex: 'singleFee',
    width: 120
  },
  {
    title: '币种',
    width: 50,
    hideInSearch: true,
    renderText: () => 'HPC'
  },
  {
    title: '最高手续费/笔',
    hideInSearch: true,
    dataIndex: 'highestFee',
    width: 120,
  },
  {
    title: '币种',
    width: 50,
    hideInSearch: true,
    renderText: () => 'HPC'
  },
  {
    title: '备注',
    hideInSearch: true,
    dataIndex: 'remark',
    width: 140
  },
  {
    title: '操作',
    hideInSearch: true,
    dataIndex: 'action',
    width: 80,
    fixed: 'right',
  },
];

export default columnsData;
